package com.jiantong.version.impl.service;

import com.jiantong.version.impl.dao.VersionControlDao;
import com.jiantong.version.model.VersionControl;
import com.jiantong.version.service.VersionControlWriteService;
import io.terminus.boot.rpc.common.annotation.RpcProvider;
import io.terminus.common.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by mz on 10/5/17.
 *
 */
@Slf4j
@Service
@RpcProvider
public class VersionControlWriteServiceImpl implements VersionControlWriteService{

    private final VersionControlDao versionControlDao;

    @Autowired
    public VersionControlWriteServiceImpl(VersionControlDao versionControlDao){
        this.versionControlDao = versionControlDao;
    }

    @Override
    public Response<Boolean> updateVersionControl(VersionControl versionControl) {
        try{
            return Response.ok(versionControlDao.update(versionControl));
        }catch (Exception e){
            log.error("failed to update versionControl");
            return Response.fail("failed to update versionControl");
        }
    }
}
